package com.lmc.gobang.config;

import com.lmc.gobang.api.GameAPI;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
//                .excludePathPatterns(
//                        "/**/*.html",
//                        "/static/image/*",
//                        "/static/js/**",
//                        "/static/css/**",
//                        "/user/login",
//                        "/user/register");
//    }
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginInterceptor())
//                .addPathPatterns("/**")
//                .excludePathPatterns(
//                        "/static/**", // 排除静态资源路径
//                        "/user/login",
//                        "/user/register",
//                        "/**/*.html"
//                );
//    }
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(
                        "/**/*.html", // 排除所有 HTML 文件
                        "/**/*.css",  // 排除所有 CSS 文件
                        "/**/*.js",   // 排除所有 JS 文件
                        "/image/*",
                        "/favicon.ico", // 排除网站图标
                        "/user/login",
                        "/user/register"
                );
    }
}
